﻿<UserControl x:Name="userControl"
             x:Class="Rio.Framework.Pages.MenuOffice.OfficePageApplicationButton"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:conv="clr-namespace:Rio.Framework.Pages.Helpers.Converter"
             mc:Ignorable="d"
             Loaded="userControl_Loaded"
             d:DesignHeight="200"
             d:DesignWidth="180">

    <UserControl.Resources>
        <conv:BitmapImageConverter x:Key="BitmapImageConverter" />
        <Style x:Key="WelcomeScreenButtonStyle"
               TargetType="Button">
            <Setter Property="Background"
                    Value="#FF1F3B53" />
            <Setter Property="Foreground"
                    Value="#FF000000" />
            <Setter Property="Padding"
                    Value="3" />
            <Setter Property="BorderThickness"
                    Value="1" />
            <Setter Property="BorderBrush">
                <Setter.Value>
                    <LinearGradientBrush EndPoint="0.5,1"
                                         StartPoint="0.5,0">
                        <GradientStop Color="#FFA3AEB9"
                                      Offset="0" />
                        <GradientStop Color="#FF8399A9"
                                      Offset="0.375" />
                        <GradientStop Color="#FF718597"
                                      Offset="0.375" />
                        <GradientStop Color="#FF617584"
                                      Offset="1" />
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition From="Normal"
                                                          GeneratedDuration="0:0:0.1"
                                                          To="MouseOver">
                                            <VisualTransition.GeneratedEasingFunction>
                                                <CircleEase EasingMode="EaseIn" />
                                            </VisualTransition.GeneratedEasingFunction>
                                        </VisualTransition>
                                        <VisualTransition From="MouseOver"
                                                          GeneratedDuration="0:0:0.1"
                                                          To="Normal">
                                            <VisualTransition.GeneratedEasingFunction>
                                                <CircleEase EasingMode="EaseIn" />
                                            </VisualTransition.GeneratedEasingFunction>
                                        </VisualTransition>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Normal" />
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <ColorAnimation Duration="0"
                                                            To="Yellow"
                                                            Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Color)"
                                                            Storyboard.TargetName="Background"
                                                            d:IsOptimized="True" />
                                            <DoubleAnimation Duration="0"
                                                             To="0"
                                                             Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.BlurRadius)"
                                                             Storyboard.TargetName="Background"
                                                             d:IsOptimized="True" />
                                            <DoubleAnimation Duration="0"
                                                             To="1"
                                                             Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)"
                                                             Storyboard.TargetName="Background"
                                                             d:IsOptimized="True" />
                                            <DoubleAnimation Duration="0"
                                                             To="0"
                                                             Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.ShadowDepth)"
                                                             Storyboard.TargetName="Background"
                                                             d:IsOptimized="True" />
                                            <ColorAnimation Duration="0"
                                                            To="#40DEF5F2"
                                                            Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)"
                                                            Storyboard.TargetName="Background"
                                                            d:IsOptimized="True" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <ColorAnimation Duration="0"
                                                            To="Yellow"
                                                            Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Color)"
                                                            Storyboard.TargetName="Background"
                                                            d:IsOptimized="True" />
                                            <DoubleAnimation Duration="0"
                                                             To="0"
                                                             Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.BlurRadius)"
                                                             Storyboard.TargetName="Background"
                                                             d:IsOptimized="True" />
                                            <DoubleAnimation Duration="0"
                                                             To="1"
                                                             Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)"
                                                             Storyboard.TargetName="Background"
                                                             d:IsOptimized="True" />
                                            <DoubleAnimation Duration="0"
                                                             To="0"
                                                             Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.ShadowDepth)"
                                                             Storyboard.TargetName="Background"
                                                             d:IsOptimized="True" />
                                            <ColorAnimation Duration="0"
                                                            To="#40DEF5F2"
                                                            Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)"
                                                            Storyboard.TargetName="Background"
                                                            d:IsOptimized="True" />
                                            <ColorAnimation Duration="0"
                                                            To="#99FFFFFF"
                                                            Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)"
                                                            Storyboard.TargetName="Background"
                                                            d:IsOptimized="True" />
                                            <ColorAnimation Duration="0"
                                                            To="#66FFFFFF"
                                                            Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)"
                                                            Storyboard.TargetName="Background"
                                                            d:IsOptimized="True" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0"
                                                             To=".55"
                                                             Storyboard.TargetProperty="Opacity"
                                                             Storyboard.TargetName="DisabledVisualElement" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStates">
                                    <VisualState x:Name="Focused">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0"
                                                             To="1"
                                                             Storyboard.TargetProperty="Opacity"
                                                             Storyboard.TargetName="FocusVisualElement" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Unfocused" />
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Border x:Name="Background"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    CornerRadius="10"
                                    Padding="5">
                                <Border.Effect>
                                    <DropShadowEffect BlurRadius="3"
                                                      ShadowDepth="3"
                                                      Opacity="0.5" />
                                </Border.Effect>
                                <Border.BorderBrush>
                                    <LinearGradientBrush EndPoint="0.5,1"
                                                         StartPoint="0.5,0">
                                        <GradientStop Color="#5811322D"
                                                      Offset="0" />
                                        <GradientStop Color="#BFFFFFFF"
                                                      Offset="1" />
                                        <GradientStop Color="#3EFFFFFF"
                                                      Offset="0.25" />
                                        <GradientStop Color="White"
                                                      Offset="0.5" />
                                        <GradientStop Color="#3EFFFFFF"
                                                      Offset="0.75" />
                                    </LinearGradientBrush>
                                </Border.BorderBrush>
                                <Border.Background>
                                    <LinearGradientBrush EndPoint="0.75,1"
                                                         StartPoint="0.25,0">
                                        <GradientStop Color="#33FFFFFF"
                                                      Offset="0" />
                                        <GradientStop Color="#33FFFFFF"
                                                      Offset="1" />
                                        <GradientStop Color="#C0FFFFFF"
                                                      Offset="0.287" />
                                        <GradientStop Color="#4011322D"
                                                      Offset="0.683" />
                                    </LinearGradientBrush>
                                </Border.Background>
                            </Border>
                            <ContentPresenter x:Name="contentPresenter"
                                              ContentTemplate="{TemplateBinding ContentTemplate}"
                                              Content="{TemplateBinding Content}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              Margin="{TemplateBinding Padding}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                            <Rectangle x:Name="DisabledVisualElement"
                                       Fill="#FFFFFFFF"
                                       IsHitTestVisible="false"
                                       Opacity="0"
                                       RadiusY="3"
                                       RadiusX="3" />
                            <Rectangle x:Name="FocusVisualElement"
                                       IsHitTestVisible="false"
                                       Margin="1"
                                       Opacity="0"
                                       RadiusY="2"
                                       RadiusX="2"
                                       Stroke="#FF6DBDD1"
                                       StrokeThickness="1" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot">
        <Button Margin="0"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Style="{StaticResource WelcomeScreenButtonStyle}"
                BorderThickness="3"
                Click="Button_Click" MaxWidth="180" MaxHeight="180">
            <StackPanel Margin="5">
                <TextBlock TextWrapping="Wrap"
                           Text="{Binding Title, ElementName=userControl}"
                           HorizontalAlignment="Center"
                           Margin="0,0,0,5"
                           FontWeight="Bold"
                           FontSize="12" />
                <Image MaxWidth="140"
                       MaxHeight="140"
                       Source="{Binding Image, Converter={StaticResource BitmapImageConverter}, ElementName=userControl}" />
            </StackPanel>
        </Button>
    </Grid>
</UserControl>
